package com.example.design.absFactory;

import com.example.design.absFactory.fruit.SouthApple;
import com.example.design.absFactory.fruit.SouthBanana;
import com.example.design.factory.FruitType;
import com.example.design.factory.interfactory.service.FruitFactory;
import com.example.design.factory.service.Fruit;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author: duk
 * @Date: 2021/12/8 16:33
 * @Description: 管理南方香蕉工厂
 */
@Component
public class SouthFruitFactory implements FruitFactory {
    @Resource
    private SouthApple southApple;
    @Resource
    private SouthBanana southBanana;
    @Override
    public Fruit getFruit(FruitType fruitType) {
        Fruit fruit = null;
        switch (fruitType){
            case BANANA:
                fruit = southBanana;
                break;
            case APPLE:
                fruit = southApple;
                break;
            default:
                break;
        }
        return fruit;
    }
}
